#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL a[N], f[N];
LL l[N], r[N];
LL n, m;
int main()
{
	//处理数据
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		cin >> a[i];
		f[i] = f[i - 1] + a[i];
	}
	cin >> m;
	for (int i = 1;i <= m;i++)
	{
		cin >> l[i] >> r[i];
	}
	//输出
	for (int i = 1;i <= m;i++)
	{
		int x = l[i], y = r[i];
		cout << f[y] - f[x - 1] << endl;
	}
	return 0;
}